First iteration on option attributes - #1231
Draft
jaapio wants to merge 6 commits into
Draft
Conversation
jaapio
force-pushed
the
task/directive-options
branch
from
March 1, 2026 19:50
0c15922 to
1823455
Compare
jaapio
force-pushed
the
task/directive-options
branch
from
August 28, 2026 14:38
e1c76b1 to
fd93e7f
Compare
The new option attribute makes it easier to validate directives. An extra advantage is that we can use the new attributes to document the directive options.
The reverse node transformer allows us to transform children of nodes before the node itself is transformed. This is needed for directives which may contain child nodes that need processing.
jaapio
force-pushed
the
task/directive-options
branch
from
August 28, 2026 14:43
fd93e7f to
f9686be
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Directive attributes & compile-time directive processing
Introduces a new attribute-based declaration system for reStructuredText directives and moves directive processing from the parse phase into the compile phase.
Moving directive processing to a compiler pass is the groundwork that enables upcoming features such as option validation — with directives now declaratively describing their options via attributes, the framework can inspect and validate them centrally instead of each directive doing ad-hoc parsing.
Features
#[Directive]and#[Option]attributesphpDocumentor\Guides\RestructuredText\Directives\Attributes\Directiveattribute declares a directive's name and aliases on the class, replacing the abstractgetName()/getAliases()methods.#[Option]attribute (OptionType, default value, description, example) declares the options a directive supports — used for automatic option validation, type coercion, and documentation.Compile-time directive processing
DirectiveNoderepresents a parsed directive during compilation and is now processed by a dedicatedDirectiveProcessPasscompiler pass instead of being resolved eagerly by the parser.ReverseNodeTransformerinterface, with support inDocumentNodeTraverser, so parent transforms run after their children.createNode(DirectiveNode)entry point; a backward-compatprocess()path (withisUpgraded()) keeps existing directives working while they are migrated.Upgraded directives
readOption()/readAllOptions()onBaseDirectivenow coerce values to the declaredOptionTypeand apply attribute defaults (e.g. youtube width/height/allow/allowfullscreen).classto the rendered node.Deprecations
#[Directive]attribute now trigger a deprecation when their name is resolved, pointing to documentation on migrating custom directives.Notes
update-security-issuesand a dependency bump.